package com.own.business.system.user.controller.manage;

import com.own.aop.permission.PermissionModule;
import com.own.aop.permission.PermissionOperation;
import com.own.business.system.user.business.service.SystemUserSecurityService;
import com.own.business.system.user.common.constant.ConstantModule;
import com.own.component.common.base.controller.BaseController;
import com.own.component.common.model.R;
import com.own.component.common.model.ResultModel;
import com.own.component.log.operation.aop.LogOperationAop;
import com.own.constant.ConstantApiPrefix;
import com.own.constant.ConstantBeanSuffix;
import com.own.constant.ConstantPermission;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * ManageSystemUserSecurityController
 *
 * @author chenxueli
 * @date 2023-08-09 15:58:28
 */
@Tag(name = "系统用户账号安全" + ConstantBeanSuffix.MANAGE_CLIENT + ConstantBeanSuffix.CONTROLLER)
@PermissionModule(ConstantModule.USER_SECURITY)
@RestController
@RequestMapping(ConstantApiPrefix.BASE_API_V1_PREFIX + ConstantApiPrefix.MANAGE_CLIENT + "system/security")
public class ManageSystemUserSecurityController extends BaseController {

    @Resource
    private SystemUserSecurityService systemUserSecurityService;

    @LogOperationAop
    @PermissionOperation(ConstantPermission.UPDATE)
    @Operation(summary = "修改某个用户的信息")
    @PostMapping("/modify/{type}/{userId}")
    public ResultModel<Boolean> modify(
            @Parameter(description = "用户id") @PathVariable Long userId,
            @Parameter(description = "修改的类型 userName,phone,email,password,sms,ip") @PathVariable String type
    ) {
        var flag = systemUserSecurityService.modifyByUserId(userId, type);
        return R.success(flag);
    }

}
